<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>秒杀管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script language="javascript" src="../script/Calendar.js"></script>
<script type="text/javascript" src="../script/jquery.validation.min.js"></script>
    <script src="../script/my_lightbox.js" language="javascript"></script>

    <script>
$(function(){
	$('#form').submit(function(){
        if (!$('#sku_id').val()) {
            alert('请选择商品');
            return false;
        };
    }).validate({
		errorPlacement: function(error, element){
			element.next('.form-error').append(error);
		},      
		rules : {
			stime:{
				required:true
			},
			etime:{
				required:true
			},
			sec_total:{
				required:true
			},
			sec_limit:{
				required:true
			},
			sec_price:{
				required:true
			}
		},
		messages : {
			etime:{
				required:'请填写开始时间',
			},
			stime:{
				required:'请填写结束时间',
			},
			sec_total:{
				required:'请填写秒杀总数',
			},
			sec_limit:{
				required:'请填写最多可买',
			},
			sec_price:{
				required:'请填写秒杀价格'
			}
		}
	});
});


                    var cdr = new Calendar("cdr");
                    document.write(cdr);
                    cdr.showMoreDay = true;
                    </script>

</head>
<body>
        <div class="flow">
            <div class="itemtitle">
                <h3>秒杀管理</h3>
                <ul>
                    <li <{if $smarty.get.operation==''}>class="current"<{/if}>><a href="?m=activity&s=spike.php"><span>管理</span></a></li>
                    <li <{if $smarty.get.operation=='add'}>class="current"<{/if}>><a href="?m=activity&s=spike.php&operation=add"><span>添加</span></a></li>
                    <{if $smarty.get.operation=='edit'}>
                    <li class="current"><a href="#"><span>修改</span></a></li>
                    <{/if}>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <div class="container">
        <{if $smarty.get.operation=='add' or $smarty.get.operation=='edit' }>
        
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" value="<{$de.id}>">
            <input name="pid" type="hidden" id="pid" value="<{$de.pid}>">
            <input name="sku_id" type="hidden" id="sku_id" value="<{$de.sku_id}>">
            <table class="table">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">添加秒杀产品</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100">秒杀产品</td>
                    <td>
                    <span id="pro_title"><{$de.pname}></span><input type="button" name="" value="选择" id="choosePro">
                    </td>
                </tr>
                <tr>
                    <td>起止时间</td>
                    <td>
                    
                    <input onFocus="cdr.show(this);" class="ltext" type="text" name="stime" id="stime" value="<{$de.start_time|date_format}>"> 
                    <{html_select_time use_24_hours=true display_seconds=false display_minutes=false prefix=start time=$de.start_time}>:00:00
                    - 
                    <input onFocus="cdr.show(this);" class="rtext" type="text" name="etime" id="etime" value="<{$de.end_time|date_format}>">
                    <{html_select_time use_24_hours=true display_seconds=false display_minutes=false prefix=end time=$de.end_time}>:59:59
                    </td>
                </tr>
                
                <tr>
                    <td width="100">显示总数</td>
                    <td>
                    <input name="sec_total" id="sec_total" type="text"  value="<{$de.sec_total|default:50}>"> 前台展示数量<div  class="form-error"></div>
                    </td>
                </tr>
                 <tr>
                    <td width="100">秒杀库存</td>
                    <td>
                    <input name="sec_true_stock" id="sec_true_stock" type="text"  value="<{$de.sec_true_stock}>"> 不可设定超过库存值（剩余<{$de.sec_stock|default:'?'}>）当前库存：<span id="stocks"><{$de.stock}></span><div  class="form-error"></div>
                    </td>
                </tr>
                <tr>
                    <td width="100">最多可买</td>
                    <td>
                    <input name="sec_limit" id="sec_limit" type="text"  value="<{$de.sec_limit|default:1}>"> 默认为 1 ，0为不限制<div  class="form-error"></div>
                    </td>
                </tr>
                <tr>
                    <td width="100">秒杀价格</td>
                    <td>
                    <input name="sec_price" id="sec_price" type="text"  value="<{$de.sec_price}>"><div  class="form-error"></div>海欧价:(<span id="price"><{$de.price}></span>) 市场价:(<span id="market_price"><{$de.market_price}></span>)
                    </td>
                </tr>
                <tr>
                    <td>活动图片</td>
                    <td>
                        <input name="pic" class="w350" type="text" id="pic" value="<{$de.pic}>" />
                        [<a href="javascript:uploadfile('上传图片','pic',750,416,'activity')">上传</a>]
                        [<a href="javascript:preview('pic');">预览</a>]
                        [<a onclick="javascript:$('#pic').val('');" href="#">删除</a>] <span class="bz"></span>
                    </td>
                </tr>
                <tr>
                    <td>开启</td>
                    <td>
                    <input type="radio" name="status" value="1" id="open" <{if $de.status==1||!$smarty.get.editid}>checked="checked"<{/if}>/><label for="open">是</label>
                    <input type="radio" name="status" value="0" id="close" <{if $de.status==0&&$smarty.get.editid}>checked="checked"<{/if}>/><label for="close">否</label>
                    </td>
                </tr>
                
                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<{if !$smarty.get.editid}>save<{else}>edit<{/if}>">
                    </td>
                </tr>
                </tbody>
            </table>
            </form>
           
    <script>
$('#choosePro').click(function(){
    window.parent.iframe_form("activity", '秒杀产品添加', '<{$config.weburl}>/admin/module.php?m=activity&s=spike_product.php&id=<{$smarty.get.editid}>&spikeid=spikeid', 800, 530);
    return false;
});

function setProName(str){

    var s= str.split(',');

    $('#pro_title').text(s[2]);

   $('#pid').val(s[1]);
   $('#sku_id').val(s[0]);
   $('#price').text(s[3]);
   $('#market_price').text(s[4]);
   $('#stocks').text(s[5]);


}


</script>
        <{else}>
		<script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });	 
        });
        </script>
        
        <table class="table">
        	<thead>
                <tr>
                <form action="" method="get">
                <input type="hidden" name="m" value="activity">
    <input type="hidden" name="s" value="spike.php">
                    <th class="partition" colspan="99">秒杀产品列表

<span style="float:right;">
<label>产品ID:</label><textarea name="product_id" style="resize:horizontal;height:18px;float:left;"><{$smarty.get.product_id}></textarea>
   <label style="margin-left:20px;">状态:</label><select name="status" style="float:left;">
   <option value="">全部</option>
    <option value="1" <{if "1"===$smarty.get.status}>selected="selected"<{/if}>>开启</option>
    <option value="0" <{if "0"===$smarty.get.status}>selected="selected"<{/if}>>关闭</option>
</select>
<label style="margin-left:20px;">秒杀日期:</label><input id="sdate" name="sdate" style="float:left;" type="text" size="12" value="<{$smarty.get.sdate}>"onFocus="cdr.show(this);" /><label>-</label>
                    <input id="edate" name="edate" style="float:left;" type="text" size="12" value="<{$smarty.get.edate}>" onFocus="cdr.show(this);" />

                    <label style="margin-left:20px;">秒杀状态:</label>
<select name="is_start" style="float:left;">
   <option value="">全部</option>
    <option value="1" <{if "1"===$smarty.get.is_start}>selected="selected"<{/if}>>进行中</option>
    <option value="2" <{if "2"===$smarty.get.is_start}>selected="selected"<{/if}>>未开始</option>
    <option value="-1" <{if "-1"===$smarty.get.is_start}>selected="selected"<{/if}>>已结束</option>
</select>
<label style="margin-left:20px;"><input type="image" src="<{$config.weburl}>/image/admin/search.gif" /></label>


</span>
                    </th>
</form>
                </tr>
            </thead>
            <form action="" method="post">
            <tbody>            
                <tr class="header">
                    <th width="20"></th>
                    <th width="20">产品ID</th>
                    <th width="20">skuID</th>
                    <th width="20"></th>
                    <th width="100">产品名称</th>
                     <th width="20">规格</th>
                    <th width="83">起止时间</th>
                    <th width="100">产品分类</th>
                    <th width="40" style="text-align:center">秒杀价</th>
                    <th width="40" style="text-align:center">海欧原价</th>
                    <th width="40" style="text-align:center">市场价</th>
                    <th width="20" style="text-align:center">显示总数</th>
                    <th width="20" style="text-align:center">秒杀库存</th>
                    <th width="20" style="text-align:center">剩余</th>
                    <th width="20" style="text-align:center">最多可买</th>
                    <th width="20" style="text-align:center">状态</th>
                    <th width="30">操作</th>
                </tr>
                <{foreach item=list from=$de.list}>
                <tr>
                    <td><input type="checkbox" value="<{$list.id}>" class="checkitem" name="chk[]"></td>
                    <td><{$list.pid}></td>
                    <td><{$list.sku_id}></td>
                    <td><div ><img width="50" src="<{$list.pic}>"></div></td>
                    <td>
                    <a href="http://wx.52ywy.com/item-<{$list.pid}>.html" target="_blank"><{$list.pname}></a></td>
                    <td><{$list.spec}></td>
                    <td><{$list.start_time|date_format:"%Y-%m-%d %H:%M"}> <br/> <{$list.end_time|date_format:"%Y-%m-%d %H:%M"}><br />
                    <span <{if $list.start_time <= $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $list.end_time}>style="color:green">(进行中<{elseif $list.start_time > $smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}>style="color:blue">(未开始<{elseif $list.end_time < $smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}>style="color:red">(已过期<{/if}>)</span>
                    </td>
                    <td><{$list.cat}></td>
                    <td style="text-align:center"><{$config.money}> <{$list.sec_price}></td>
                    <td style="text-align:center"><{$config.money}><{$list.price}></td>
                    <td style="text-align:center"><{$config.money}><{$list.market_price}></td>
                    <td style="text-align:center"><{$list.sec_total}></td>
                    <td style="text-align:center"><{$list.sec_true_stock}></td>
                    <td style="text-align:center"><{$list.sec_stock}></td>
                    <td style="text-align:center"><{$list.sec_limit}></td>
                    <td style="text-align:center"><{if $list.status =='1'}>开启<{else}>关闭<{/if}></td>
                    <td>
                    <a href="?m=activity&s=spike.php&operation=edit&editid=<{$list.id}>"><{$editimg}></a> 
                    <a onclick="return confirm('确定删除吗');" href="?m=activity&s=spike.php&delid=<{$list.id}>"><{$delimg}></a> 
                    <!--<{if $list.catid==-1}><a href='?m=activity&s=activity_product_list.php&editid=<{$list.id}>'><{$setimg}><{/if}></a>-->
                    </td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <{/foreach}>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="99">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" value="删除" />
                    	<div class="page"><{$de.page}></div>
                    </td>
                </tr>
            </tfoot>
                    </form>
        </table>

        <{/if}>
    </div>
</body>
</html>